add_executable(TestVC4CL "")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  target_compile_options(TestVC4CL PRIVATE -Wno-ignored-attributes -Wno-deprecated-declarations)
endif()
target_link_libraries(TestVC4CL VC4CL cpptest-lite ${SYSROOT_LIBRARY_FLAGS})
target_compile_options(TestVC4CL PRIVATE ${VC4CL_ENABLED_WARNINGS})

include(sources.list)

if(VC4C_TEST_DATA_LIBRARY AND VC4C_TEST_DATA_INCLUDE)
  message(STATUS "Activating VC4C TestData tests")
  target_include_directories(TestVC4CL PRIVATE ${VC4C_TEST_DATA_INCLUDE})
  target_compile_definitions(TestVC4CL PRIVATE HAS_TEST_DATA=1)
  target_link_libraries(TestVC4CL ${VC4C_TEST_DATA_LIBRARY})
endif()

if(NOT TARGET cpptest-lite)
  target_include_directories(TestVC4CL PRIVATE ${PROJECT_SOURCE_DIR}/lib/cpptest-lite/include ${PROJECT_SOURCE_DIR})
  add_dependencies(TestVC4CL cpptest-lite-project-build)
  add_library(cpptest-lite SHARED IMPORTED)
  ExternalProject_Get_Property(cpptest-lite-project BINARY_DIR)
  set_target_properties(cpptest-lite PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/libcpptest-lite.so")
endif()

if(MOCK_HAL)
	target_compile_definitions(TestVC4CL PRIVATE MOCK_HAL=1)
endif(MOCK_HAL)
if(ENABLE_COVERAGE)
	target_compile_options(TestVC4CL PRIVATE -fprofile-arcs -ftest-coverage --coverage)
	target_link_libraries(TestVC4CL gcov "-fprofile-arcs -ftest-coverage")
endif(ENABLE_COVERAGE)

add_test(NAME System COMMAND TestVC4CL --system WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Platform COMMAND TestVC4CL --platform WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Device COMMAND TestVC4CL --device WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Context COMMAND TestVC4CL --context WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Queue COMMAND TestVC4CL --queue WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Buffer COMMAND TestVC4CL --buffer WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Images COMMAND TestVC4CL --images WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Programs COMMAND TestVC4CL --programs WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Kernel COMMAND TestVC4CL --kernels WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Events COMMAND TestVC4CL --events WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME Executions COMMAND TestVC4CL --executions WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
